package com.tian.view.common

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.tian.view.BaseRecyclerAdapter
import com.tian.view.R

/**
 * @author tiansongtao, Email:tiansongtao@up366.com
 * @date 2022/12/13 18:19
 */
abstract class BaseListActivity : AppCompatActivity() {

    lateinit var mRecyclerView: RecyclerView

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.recycler_view_list)
        mRecyclerView = findViewById(R.id.rv_list)
        mRecyclerView.layoutManager = LinearLayoutManager(this)
        val adapter = getRecyclerViewAdapter()
        mRecyclerView.adapter = adapter
        adapter.datas = getAdapterData()
    }

    abstract fun getRecyclerViewAdapter(): BaseRecyclerAdapter

    abstract fun getAdapterData(): MutableList<BaseRecyclerAdapter.DataHolder>
}